import requests
from loguru import logger


class Base:
    def send_request(self,api_name,data:dict)->requests.Response:
        logger.info(f"接口：({api_name})-接口参数为{data}")
        response = requests.request(**data)
        logger.info(f"接口:({api_name})接口相应信息为:({response.text})")
        return response

class Login(Base):
    def __init__(self):
        self.server_token = self._server_login()
    def _server_login(self):
        data = {
            "url": "http://124.70.39.201/adminapi/login?username=admin&password=123123",
            "method": "get"
        }
        return self.send_request(self._server_login.__name__, data).json()["data"]["token"]


if __name__ == '__main__':
    login = Login()
    print(login.server_token)
